﻿<div class="row">
    <div class="col-xs-12 col-md-12 col-lg-12">
        <div class="widget">
            <div class="widget-header bg-blue">
            	<i class="widget-icon fa fa-arrow-left"></i>
                <span class="widget-caption">瑕疵管理</span>
                <div class="widget-buttons">
                    <a href="#" data-toggle="maximize">
                        <i class="fa fa-expand"></i>
                    </a>
                    <a href="#" data-toggle="collapse">
                        <i class="fa fa-minus"></i>
                    </a>
                    <a href="#" data-toggle="dispose">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="widget-body" style="height: auto;">
	
				<div class="table-toolbar">
					<a href="{:U('Admin/Infrastructure/defect_set')}" class="btn btn-primary" data-loader="bb-loader" data-loadername="新增产品" >
						<i class="fa fa-plus"></i>新增瑕疵
					</a>
					<div class="pull-right"></div>
				</div>
				<table class="table table-hover table-striped table-bordered">
                    <thead class="bordered-blueberry">
                        <tr role="row">
                        	<th style="width: 20px;">
                        		<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
									<label style="padding-left: 4px;"> <input type="checkbox" class="bb-checkall colored-blue">
                                     <span class="text"></span>
									</label>                                    
                                </div>
                        	</th>
                        	<th>瑕疵名</th>
                        	<th style="width: 155px;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<volist name="cache" id="vo">
                    		<tr>
                    			<td>
								<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
									<label style="padding-left: 4px;"> <input name="checkvalue" type="checkbox" class="colored-blue bb-check" value="{$vo.id}">
                                     <span class="text"></span>
									</label>                                    
                                </div>
							</td>
                    			<td>{$vo.title}</td>
                    			<td align="center">
                    				<a href="{:U('Admin/Infrastructure/defect_set',array('id'=>$vo['id']))}" class="btn btn-primary btn-xs" data-loader="bb-loader" data-loadername="修改会员" ><i class="fa fa-edit"></i> 修改 </a>
                    				<a href="#" data-id="{$vo.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除 </a>
                    			</td>
                    		</tr>
                    	</volist>
                    </tbody>
                </table>
               <div class="row DTTTFooter">{$page}</div>
            </div>
        </div>
    </div>
</div>

<!--面包屑导航封装-->
<div id="tmpbread" style="display: none;">{$breadhtml}</div>
<script type="text/javascript">
	setBread($('#tmpbread').html());
</script>

<script type="text/javascript">
	//全选
	var checkall=$('.bb-checkall');
	var checks=$('.bb-check');
	var trs=$('table tbody tr');
	$(checkall).on('click',function(){
		if($(this).is(":checked")){			
			$(checks).prop("checked","checked");
		}else{
			$(checks).removeAttr("checked");
		}		
	});
	$(trs).on('click',function(){
		var c=$(this).find("input[type=checkbox]");
		if($(c).is(":checked")){
			$(c).removeAttr("checked");
		}else{
			$(c).prop("checked","checked");
		}		
	});
	
	//删除
	$('.delete').on('click',function(){
		var id=$(this).data('id');
		if(id){
			var chk=id;
		}else{
			var checks=$(".bb-check:checked");
			var chk='';
			$(checks).each(function(){
				chk+=$(this).val()+',';
			});
		}

		if(!chk){
			$.bb.alert('danger','请选择要删除的产品！');
			return false;
		}
		
		$.ajax({
			type:"post",
			url:"{:U('Admin/Infrastructure/defect_del')}",
			data:{'ids':chk},
			dataType: "json",
			success: function (info) {
				$.bb.loading();
				if(info.status){
					$.bb.alert('success',info.msg);
					$('#refresh-toggler').trigger('click');
					return false;
				}else{
					$.bb.alert('danger',info.msg);
					
				}
			},
			error:function(xhr){
				$.bb.alert('danger','通讯失败！请重试！');
			}
		});
	});
</script>
